<!doctype html>
<html lang="en">
<head><meta charset="UTF-8">
    <title>幸运数字游戏</title>
    <script type="text/javascript">
        function $(id){return document.getElementById(id);}
        var m=Number(0);
        var n=Number(0);
        function createInt()
        {
            var a=Number(0);
            var array_int = new Array();
            for (var i = 0; i < 3; i++)
            {
                array_int[i] = Math.round((Math.random() * (9 - 1) + 1));
            }
            n=n+1;
            for (var i = 0; i < 3; i++)
            {
                if (array_int[i] == 8)
                {
                    m = m + 1;
                    break;
                }
            }
            a=m/n*100;
            $("array_num1").value = array_int.join(",");
            $("m").value = m;
            $("a").value=a;
        }
        function f() {
            m=0;
            n=0;
        }
    </script></head>
<body>
<form method="post" action="" name="myform">
    <fieldset style="width:350px;height:150px;text-align:center;">
        <legend align="center">幸运数字游戏</legend>
        产生数组:<input type="text" name="" id="array_num1" size="30" readonly><br><br>
        胜利次数:<input type="text" name="" id="m" size="30" readonly><br><br>
        胜率:<input type="text" name="" id="a" size="30" readonly>%<br><br>
        <input type="button" value="产生3个随机整数" onclick="createInt();">
        <input type="reset" onclick="f()";>
    </fieldset>
</form></body>
</html>
